package com.dp;

public class Solution17 {
    public int findMaxForm(String[] strs, int m, int n) {
        int[][] dp = new int[m+1][n+1];
        int x,y;
        for (String str : strs) {
            char[] chars = str.toCharArray();
            x=0;y=0;
            for (char c : chars) {
                if (c == '0') x++;
                else y++;
            }
            for (int i = m; i >= x; i--) {
                for (int j = n; j >= y; j--) {
                    dp[i][j] = Math.max(dp[i][j],dp[i-x][j-y]+1);
                }
            }
        }
        return dp[m][n];
    }
}
